<?php 

namespace App\Services;

class CustomService {
	public function clearCustom() {
		$params = [
			'service' => 'alipay.acquire.customs',
			'partner' => '',
			'_input_charset' => 'utf-8',
			'sign_type' => 'MD5',
			'out_request_no' => date('Ymd').random_int(1000, 9999),
			'trade_no' => '2020041446800462000100021584',
			'merchant_customs_code' => '',
			'amount' => 2.99,
			'customs_place' => 'zongshu',
		];	

		$this->makeSign($params);	
	}

	public function makeSign($data) {
		$data = array_diff_key($data, ['sign_type' => 1]);
		ksort($data);
		$str = '';
		foreach($data as $k => $v) {
			$str .= $str ? '&'.$k.'='.$v : $k.'='.$v;
		}
		echo $str;
	}
}